//
//  ViewController.m
//  Demo
//
//  Created by lx on 2018/12/25.
//  Copyright © 2018 mgz. All rights reserved.
//

#import "ViewController.h"
#import <Masonry.h>
#import "IGListTableViewDemo.h"
#import "HeroDemoVC.h"
#import "AsynDemoVC.h"
#import "RacVC.h"
#import "MGZImgsVC.h"
#import "YTKVC.h"
#import "LazyScrollDemoVC.h"
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong)NSMutableArray *dataArr;

@property (nonatomic,strong)UITableView *tableView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    [self bindView];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellId = @"Demo";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    if (self.dataArr.count > 0) {
        cell.textLabel.text = self.dataArr[indexPath.row];
    }
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    switch (indexPath.row) {
        case 0:
        {
            IGListTableViewDemo *vc = [[IGListTableViewDemo alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
        break;
            
        case 1:
        {
            AsynDemoVC *vc = [[AsynDemoVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 2:
        {
            HeroDemoVC *vc = [[HeroDemoVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
        case 3:
        {
            RacVC *vc = [[RacVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 4:
        {
            MGZImgsVC *vc = [[MGZImgsVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
        case 5:{
            YTKVC *vc = [[YTKVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
        case 6:{
            LazyScrollDemoVC *vc = [[LazyScrollDemoVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
        default:
            break;
    }
}


- (void)bindView{
    self.title = @"目录";
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.and.left.right.bottom.mas_equalTo(self.view);
    }];
    [self.tableView reloadData];
}

- (UITableView *)tableView{
    if (_tableView == nil) {
        _tableView = [[UITableView alloc]init];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableFooterView = [UIView new];
    }
    return _tableView;
}

- (NSMutableArray *)dataArr{
    if (_dataArr == nil) {
        _dataArr = [[NSMutableArray alloc]initWithArray:@[@"IGListDemo",@"AsyncDisplayKit",@"Hero",@"RAC",@"MGZImgsView",@"YTKVC",@"LazyScrollDemoVC"]];
    }
    return _dataArr;
}

@end
